package com.hs.sfzy.service.impl;

import com.hs.sfzy.entity.Carousel;
import com.hs.sfzy.mapper.CarouselMapper;
import com.hs.sfzy.service.CarouselService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CarouselServiceImpl implements CarouselService {
    @Autowired
    private CarouselMapper carouselMapper;

    private static final String BASE_IMAGE_URL = "http://localhost:8080/";

    @Override
    public List<Carousel> selectAllCarousel() {
        List<Carousel> carouselList = carouselMapper.selectAllCarousel();

        // 拼接完整的网络路径
        for (Carousel carousel : carouselList) {
            String imageName = carousel.getImage();
            carousel.setImage(BASE_IMAGE_URL + imageName);
        }

        return carouselList;
    }
}
